Skip to content

Conversation

@aisk
Copy link
Contributor

@aisk aisk commented Jan 11, 2026

aisk and others added 2 commits January 12, 2026 00:07
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@AlexWaygood AlexWaygood added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jan 11, 2026
Copy link
Member

@johnslavik johnslavik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could additionally clarify the implications of this?

E.g. "NamedTuple is now a function that can be used as a class base. It is no longer a class, so it cannot be used with isinstance(), issubclass() and other routines that are expected to work for class objects" .

Similar for TypedDict.

(Prior to these changes isinstance() et al. would work).

I figured this while wondering if we could briefly say why these constructs are no longer classes, and that's what the explanations from GH-84366 and GH-84368 tell me would be the most fitting here.

@AlexWaygood
Copy link
Member

AlexWaygood commented Jan 11, 2026

@johnslavik, I'm not sure I agree -- I don't think we should devote too much space in the typing docs for this. As @JelleZijlstra said on the issue, exactly what kind of objects these symbols are at runtime is an implementation detail that most users shouldn't worry about. Giving too much space in the docs for these details would give the incorrect impression that these are things that users need to understand, when they're almost always not.

@AlexWaygood AlexWaygood merged commit e22b685 into python:main Jan 11, 2026
32 checks passed
@miss-islington-app
Copy link

Thanks @aisk for the PR, and @AlexWaygood for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Jan 11, 2026
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 11, 2026
…pythonGH-143692)

(cherry picked from commit e22b68568a30e65358f6036e4d0e5505d0f76fcb)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 11, 2026
…pythonGH-143692)

(cherry picked from commit e22b685)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Jan 11, 2026

GH-143696 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jan 11, 2026
@bedevere-app
Copy link

bedevere-app bot commented Jan 11, 2026

GH-143697 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jan 11, 2026
@AlexWaygood
Copy link
Member

Thanks @aisk!

@aisk aisk deleted the typing-doc-correct branch January 11, 2026 15:58
AlexWaygood added a commit that referenced this pull request Jan 11, 2026
GH-143692) (#143696)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood added a commit that referenced this pull request Jan 11, 2026
GH-143692) (#143697)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@Viicos
Copy link
Contributor

Viicos commented Jan 11, 2026

This broke references to the TypedDict class attributes such as __total__. They are still documented, but as top level attributes of the typing module, e.g. https://docs.python.org/3/library/typing.html#typing.__total__:

image

And so breaks Sphinx cross references.

@AlexWaygood
Copy link
Member

This broke references to the TypedDict class attributes such as __total__. They are still documented, but as top level attributes of the typing module, e.g. docs.python.org/3/library/typing.html#typing.__total__:

Ah, because functions cannot have attributes, according to Sphinx? That's too bad. Great catch @Viicos.

@aisk, would you be able to make a PR reverting just the change from .. class:: TypedDict to .. function:: TypedDict? I think that's the only problematic bit of this PR, right?

@Viicos
Copy link
Contributor

Viicos commented Jan 11, 2026

Ah, because functions cannot have attributes, according to Sphinx? That's too bad.

Yeah that might be it. I'm wondering if it would make sense to document them as data elements instead, like some other special forms such as Annotated? This would be in line with what you mentioned Alex in your previous comment.

@johnslavik
Copy link
Member

johnslavik commented Jan 11, 2026

This broke references to the TypedDict class attributes such as __total__. They are still documented, but as top level attributes of the typing module, e.g. docs.python.org/3/library/typing.html#typing.__total__:

Ah, because functions cannot have attributes, according to Sphinx? That's too bad. Great catch @Viicos.

@aisk, would you be able to make a PR reverting just the change from .. class:: TypedDict to .. function:: TypedDict? I think that's the only problematic bit of this PR, right?

Oops, I've read this right after making that PR #143702

@AlexWaygood
Copy link
Member

Yeah that might be it. I'm wondering if it would make sense to document them as data elements instead, like some other special forms such as Annotated? This would be in line with what you mentioned Alex in your previous comment.

That works for me if Sphinx renders it okay!

@JelleZijlstra
Copy link
Member

Yeah data makes sense to me. Whether they're classes or functions is an implementation detail that we should be free to change again later. data leaves it unspecified. (I'm not sure we need the versionchanged notes about changes from function to class either.)

@aisk
Copy link
Contributor Author

aisk commented Jan 12, 2026

@AlexWaygood Sorry for breaking this. I went to sleep after submitting this, so I only just saw the notification.

@johnslavik Thanks for fixing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants